package com.nandi.deviceinstall.weight.imagepicker;

import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bumptech.glide.request.RequestOptions;
import com.lzy.imagepicker.loader.ImageLoader;
import com.nandi.deviceinstall.R;
import com.nandi.deviceinstall.common.Constant;
import com.nandi.deviceinstall.util.SharedTool;

import java.io.File;

/**
 * Created by qingsong on 2018/5/5.
 */

public class GlideImageLoader implements ImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {


        RequestOptions requestOptions = new RequestOptions().error(R.mipmap.default_image)
                .placeholder(R.mipmap.default_image).diskCacheStrategy(DiskCacheStrategy.ALL);

        Glide.with(activity)
                //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
                .load(Uri.fromFile(new File(path)))
                //.load(new GlideUrl(path, headers))
                .apply(requestOptions)
                .into(imageView);

    }

    @Override
    public void clearMemoryCache() {
        //这里是清除缓存的方法,根据需要自己实现
    }
}
